package com.course.finalproject.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.course.finalproject.R;

/**
 * Class that represent the main activity.
 * @author	Mariano Bessone <mariano.bessone @ tallertechnologies.com>
 * @since	2012-09-06
 */
public class MainActivity extends Activity implements OnClickListener {
	
	/** Buttons. */
	private Button weatherButton;
	private Button batteryButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    	// Super call and set content view.
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        // Weather button.
        weatherButton = (Button) findViewById(R.id.weather_button);
		weatherButton.setOnClickListener(this);
		// Battery button.
		batteryButton = (Button) findViewById(R.id.battery_button);
		batteryButton.setOnClickListener(this);
    }
    
    /**
     * Handles each click on this activity.
     * 
     * @param v View that was clicked.
     */
    public void onClick(View v) {
    	// Handles each possible button click.
    	if ( v.getId() == weatherButton.getId() ) {
    		startWeatherActivity();
		} else if ( v.getId() == batteryButton.getId() ) {
			startBatteryActivity();
		}
	}
    
    /**
     * Starts the weather activity.
     */
    private void startWeatherActivity() {
    	Intent intent = new Intent(this, WeatherActivity.class);
		startActivity(intent);
    }
    
    /**
     * Starts the battery activity.
     */
    private void startBatteryActivity() {
    	Intent intent = new Intent(this, BatteryActivity.class);
		startActivity(intent);
    }
    
}
